import Other from "./other"
import { createContext,useState } from "react"

type themeContext = {
    color: string
}
type themeContent = {
    text: string
}
// 一个context
export let theme = createContext<themeContext>({color:'red'})
// 两个context
export let context = createContext<themeContent>({text:'react从入门到放弃'})

const UseContextCom = () => {
    let [themeColor,setThemeColor] = useState<themeContext>({color:'deeppink'})

    setTimeout(() => {
        setThemeColor({color:'deepskyblue'})
    },2000)
    return(
        <fieldset>
            <legend>UseContext</legend>
            <theme.Provider value={themeColor}>
            {/* <theme.Provider value={{color:'deeppink'}}> */}
                <context.Provider value={{text:'vue从入门到放弃'}}>
                    <Other />
                </context.Provider>
            </theme.Provider>
        </fieldset>
        )
}
export default UseContextCom